import { parseQuery } from '@gnlab/utils/url'
import type { TokenEvent } from './definition'
import { TOKEN_EVENT_NAME } from './definition'

const { token } = parseQuery(window.location.search)
if (typeof token === 'string') {
  window.parent.postMessage({ type: TOKEN_EVENT_NAME, token } as TokenEvent, '*')
}

document.getElementById(token ?? '' ? 'success' : 'error')!.style.display = 'block'
